<script type="text/javascript" src="<?php echo ThemePath(); ?>/js/bootslider.js"></script>
<?php
if (!isset($model->backendUser->username)) {
    $userid = $model->users->id;
    $profileData = Profiles::model()->find('user_id=:user_id ', array(':user_id' => (int) $userid));
    $uname = $profileData->first_name;
} else {
    $uname = $model->backendUser->username;
    $uid = $model->backendUser->id;
    $userid = 'backend/' . $uid;
}



$this->pageTitle = 'View My Classes';
$this->menu = array(
    array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('asigntotrainner')),
    array('label' => Yii::t('app', 'Manage') . ' ' . $model->label(2), 'url' => array('admin')),
    array('label'=>Yii::t('app', 'Update') . ' ' . $model->label(), 'url'=>array('update', 'id' => $model->id)),
);
?>

<h3 style="text-align: left;"><?php echo Yii::t('app', 'View Class information'); ?></h3>
<h3 style="text-align: left;">Created By:<?php echo $uname; ?></h3>

<?php
$this->widget('zii.widgets.CDetailView', array(
    'data' => $model,
    'attributes' => array(
        'class_titile',
        'class_tag_description',
        array('name' => 'category_id', 'value' => $model->category->name,),
        array('name' => 'class_type_id', 'value' => $model->classType->name,),
        array('name' => 'classesTargetAudiences', 'value' => classes::getTargetAudience($model)),
        array('name' => 'difficulty_type', 'value' => ($model->difficulty_type == '1' ? 'Beginner' : ($model->difficulty_type == '2' ? 'Intermediate' : ($model->difficulty_type == '3' ? 'Advance' : 'No data')))),
        array('name' => 'class_short_description', 'type' => 'html', 'value' => $model->class_short_description,),
        array('name' => 'class_description', 'type' => 'html', 'value' => $model->class_description,),
        array('name' => 'class_outcome', 'type' => 'html', 'value' => $model->class_outcome,),
        array('name' => 'class_prerequisites', 'type' => 'html', 'value' => $model->class_prerequisites,),
        array('name' => 'class_other_information', 'type' => 'html', 'value' => $model->class_other_information,),
        array('name' => 'status', 'type' => 'image', 'htmlOptions' => array('class' => 'gridmaxwidth', 'style' => 'width: 15px !important'), 'value' => SkillConfig::status($model),),
        array('name' => 'certificate', 'value' => ($model->certificate == 1) ? 'Yes' : 'No',),
        'create_time',
        'update_time',
    ),
));
?>
<?php
$this->beginWidget('zii.widgets.CPortlet', array(
    'title' => 'View Class Venues Batch Details',
));
$classWithVenue = classes::getclassWithVenues($model->id);
$venueTotalCount = count($classWithVenue);
$venueCount = 1;
/* -------------------- Loop for print Venue start------------------------------------ */
foreach ($classWithVenue as $value) {
    $classVenue = ClassVenue::model()->findbyPk($value['class_venue_id']);
    ?>
    <h3 style="text-align:left;"><?php echo 'Venue-' . $venueCount; ?>    </h3>
    <table class="table table-striped  table-bordered table-condensed">
        <tbody>
            <tr><td> Venue Name</td><td> Venue Locality </td><td>Address Line1</td><td>Address Line2</td><td>City</td><td>State</td> <td>Country</td><td>Zip Code</td></tr>
            <tr><td> <?php echo $classVenue->name; ?></td><td> <?php echo $classVenue->venue_locality; ?></td><td><?php echo $classVenue->address_line1; ?></td><td><?php echo $classVenue->address_line2; ?></td>
                <td><?php echo $classVenue->city->city_name; ?></td><td><?php echo $classVenue->state->name; ?></td> <td><?php echo $classVenue->country->name; ?></td><td><?php echo $classVenue->zip_code; ?></td></tr>
            <?php
            /* -------------------- Loop for print Batch details Start------------------------------------ */
            $classStructure = classes::getClassBatch($model->id, $value['class_venue_id']);
            $bacth = 1;
            foreach ($classStructure as $batchValue) {
                ?>
                <tr><td colspan="7" style="background-color: blue;color: #fff;"><span class="classvenueView"><?php echo 'Batch-' . $bacth; ?> </span></td></tr>
                <tr><td colspan="7" style="background-color: #fff;">
                        <table class="table table-striped  table-bordered table-condensed">
                            <tbody>
                                <tr>  <td class="tdleft">Start date</td> <td class="tdleft">Start Time</td><td class="tdleft">End Time</td> <td class="tdleft">Price</td><td class="tdleft">Seats</td></tr>
                                <tr  style="background-color: #fff;"> <td class="tdleft"><?php echo $batchValue['start_date'] ?></td> <td class="tdleft"><?php echo $batchValue['start_time'] ?></td> <td class="tdleft"><?php echo $batchValue['end_time'] ?></td> <td class="tdleft"><?php echo $batchValue['price'] ?></td><td class="tdleft"><?php echo $batchValue['seats'] ?></td></tr>
                                <?php
                                /* --------------------  batch  EarlyDiscount  details Start------------------------------------ */
                                $classEarlyDiscount = classes::getClassBatchEarlyBirdDiscount($model->id, $batchValue['id']);
                                $classEarlyDiscountCount = count($classEarlyDiscount);
                                ?>
                                <tr><td colspan="5" style="background-color: #a30c22"><span class="classvenueView"><?php echo 'Add Early Discounts(' . $classEarlyDiscountCount . ')'; ?> </span></td></tr>
                                <tr>
                                    <td colspan="7">
                                        <table class="table table-striped  table-bordered table-condensed">
                                            <tbody>
                                                <tr>  <td class="tdleft">Discount Price</td> <td class="tdleft">In Percentage</td><td class="tdleft">Valid To</td> </tr>
                                                <?php
                                                /* -------------------- Loop for EarlyDiscount print  details Start------------------------------------ */
                                                foreach ($classEarlyDiscount as $classEarlyValue) {
                                                    echo '<tr>  <td class="tdleft">' . $classEarlyValue['discount_price'] . '</td> <td class="tdleft">' . $classEarlyValue['in_percentage'] . '</td><td class="tdleft">' . $classEarlyValue['valid_to'] . '</td> </tr>';
                                                }
                                                ?>

                                            </tbody>
                                        </table> 
                                    </td></tr><?php
                                /* -------------------- Batch  EarlyDiscount  details End------------------------------------ */
                                /* --------------------   Batch  GroupDiscount  details Start------------------------------------ */
                                $classGroupDiscount = classes::getClassBatchGroupDscount($model->id, $batchValue['id']);
                                $classGroupDiscountCount = count($classGroupDiscount);
                                ?>
                                <tr><td colspan="5" style="background-color: #4e4e4e"><span class="classvenueView"><?php echo 'Add Group Discounts(' . $classGroupDiscountCount . ')'; ?> </span></td></tr>
                                <tr><td colspan="7"><table class="table table-striped  table-bordered table-condensed">
                                            <tbody>
                                                <tr>  <td class="tdleft">Discount Price</td> <td class="tdleft">In Percentage</td><td class="tdleft">Group Zise</td> </tr>
                                                <?php
                                                /* -------------------- Loop for GroupDiscount print  details Start------------------------------------ */
                                                foreach ($classGroupDiscount as $classGroupValue) {
                                                    echo '<tr>  <td class="tdleft">' . $classGroupValue['discount_amount'] . '</td> <td class="tdleft">' . $classGroupValue['discount_in_percentage'] . '</td><td class="tdleft">' . $classGroupValue['group_size'] . '</td> </tr>';
                                                }
                                                ?>
                                            </tbody></table></td></tr>
                                <?php
                                /* -------------------- Batch  GroupDiscount  details End------------------------------------ */
                                /* -------------------- Batch Schedule   details start------------------------------------ */
                                if ($batchValue['schedule_id'] == 4) {
                                    $customeSechedule = Classes::getCustomeSechedule($model->id, $batchValue['id'])
                                    ?>

                                    <tr><td colspan="5" style="background-color: #4e4e4e"><span class="classvenueView"><?php echo 'Schedule Details(' . count($customeSechedule) . ')'; ?> </span></td></tr>
                                    <tr><td colspan="7"><table class="table table-striped  table-bordered table-condensed">
                                                <tbody>
                                                    <tr>  <td class="tdleft">Start date</td> <td class="tdleft">Start Time</td><td class="tdleft">End Time</td> </tr>
                                                    <?php
                                                    foreach ($customeSechedule as $customeSecheduleValue) {
                                                        echo '<tr>  <td class="tdleft">' . $customeSecheduleValue['date'] . '</td> <td class="tdleft">' . $customeSecheduleValue['start_time'] . '</td><td class="tdleft">' . $customeSecheduleValue['end_time'] . '</td> </tr>';
                                                    }
                                                    ?>
                                                </tbody></table></td></tr>
                                    <?php
                                } else {
                                    ?> 
                                    <tr><td colspan="5" style="background-color: #4e4e4e"><span class="classvenueView"><?php echo 'Schedule Details'; ?> </span></td></tr>

                                    <tr><td colspan="7"><table class="table table-striped  table-bordered table-condensed">
                                                <tbody>
                                                    <tr>  <td class="tdleft">Schedule type</td> </tr>

                                                    <tr>  <td class="tdleft"><?php Classes::getSchedulename($batchValue['schedule_id']); ?></td> </tr>

                                                </tbody></table></td></tr>
                                    <?php
                                }
                                ?>
                                <?php
                                $classStructure = classes::getClassStructure($model->id, $batchValue['id']);
                                $classStructureCount = count($classStructure);
                                ?>

                                <tr><td colspan="5" style="background-color: #a30c22"><span class="classvenueView"><?php echo 'Class Structure(' . $classStructureCount . ')'; ?> </span></td></tr>
                                <tr>								
                                    <td colspan="7">
                                        <table class="table table-striped  table-bordered table-condensed">
                                            <tbody>
                                                <tr>  <td class="tdleft">Start Time</td> <td class="tdleft">End Time</td><td class="tdleft">Description</td> </tr>


                                                <?php
                                                if (!empty($classStructure)) {
                                                    foreach ($classStructure as $value) {
                                                        ?><tr>  <td class="tdleft"><?php echo $value['start_time'] ?>&nbsp;&nbsp;Min</td> <td class="tdleft"><?php echo $value['end_time'] ?>&nbsp;&nbsp;Min</td> <td class="tdleft"><?php echo $value['description'] ?></td></tr>
                                                        <?php
                                                    }
                                                } else {
                                                    echo '<tr>No Class Structure Found</tr>';
                                                }
                                                ?>

                                            </tbody>
                                        </table> 
                                    </td></tr>


                            </tbody>
                        </table>
                        <?php
                        $bacth++;
                    }
                    /* -------------------- Batch  Batche day & date  Sessions  details start------------------------------------ */
                    ?>
        </tbody></table>    <hr class="hrclass"/><?php
    $venueCount++;
}
/* -------------------- Loop for print Venue End------------------------------------ */
?>

<?php
$this->endWidget();
?>


<?php
$this->beginWidget('zii.widgets.CPortlet', array(
    'title' => 'View Fun and Learnings',
));
?>
<table class="table table-striped  table-bordered table-condensed">
    <tbody>
        <tr><td class="tdleft">Fun Quotient</td> <td>Learn Quotient</td> </tr>
        <tr><td class="tdleft"> 
                <?php
                $funLearing = Classes::getfunlearing($model->id);
                $this->widget('CStarRating', array(
                    'name' => 'FunLearning[fun]',
                    'value' => ($funLearing != '') ? $funLearing->fun : '',
                    'minRating' => 0.5,
                    'readOnly' => TRUE,
                    'ratingStepSize' => 0.5,
                    'maxRating' => 5,
                ));
                ?>

            </td> <td> <?php
                $this->widget('CStarRating', array(
                    'name' => 'FunLearning[learn]',
                    'value' => ($funLearing != '') ? $funLearing->learn : '',
                    'minRating' => 0.5,
                    'readOnly' => TRUE,
                    'ratingStepSize' => 0.5,
                    'maxRating' => 5,
                ));
                ?>
            </td> </tr>
    </tbody>

</table>
<?php
$this->endWidget();
?>


<?php
$this->beginWidget('zii.widgets.CPortlet', array(
    'title' => 'View class Images',
));
?>        


<div style="width: 59%;margin: 0 auto;"> <?php
    $classWithImage = Classes::getclassWithImage($model->id);
    if (!empty($classWithImage)) {
        ?>
        <div id="slider-fixed-banner" class="carousel slide">
            <div class="carousel-inner"><?php
                foreach ($classWithImage as $value) {
                    ?>
                    <div class="<?php echo ($value['primary_image'] != '0') ? 'active' : ''; ?>  item">
                        <?php echo '<img src="' . baseUrl() . '../../' .getUploadDir(). SkillConfig::getClassCourseImagePath($userid) . 'details-image/' . $value['photo'] . '"  alt="">'; ?>

                    </div>

                <?php }
                ?>
            </div>

            <a class="left carousel-control" href="#slider-fixed-banner" data-slide="prev">&lsaquo;</a>
            <a class="right carousel-control" href="#slider-fixed-banner" data-slide="next">&rsaquo;</a>
        </div><?php
    }
    ?> 
</div>

<?php
$this->endWidget();
?>



